package com.ruoyi.produce.service.impl;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.produce.domain.TraceTask;
import com.ruoyi.produce.mapper.TraceTaskMapper;
import com.ruoyi.produce.service.ProductService;

import com.ruoyi.system.api.RemoteFarmerService;
import com.ruoyi.system.api.RemoteLogisticsService;
import com.ruoyi.system.api.domain.TraceTransport;
import com.ruoyi.system.api.domain.vo.CropsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private TraceTaskMapper traceTaskMapper;
    @Autowired
    RemoteFarmerService remoteFarmerService;
    @Autowired
    RemoteLogisticsService remoteLogisticsService;



    @Override
    public List<CropsVo> queryCropsList(Integer deptId) {
        R<List<CropsVo>> listR = remoteLogisticsService.queryCropsList(deptId,SecurityConstants.INNER);
        return listR.getData();
    }

    @Override
    public int addTask(TraceTask traceTask) {
        return traceTaskMapper.insertSelective(traceTask);
    }

    @Override
    public int updateMachingStatus(CropsVo cropsVo) {
        R<Integer> integerR = remoteFarmerService.updateMachingStatus(cropsVo, SecurityConstants.INNER);
        return integerR.getData();
    }

    @Override
    public TraceTask queryTaskByCropsId(String cropsId) {
        return traceTaskMapper.queryTaskByCropsId(cropsId);
    }

    @Override
    public int updateProductWriteStatus(String cropsId) {
        R<Integer> integerR = remoteFarmerService.updateProductWriteStatus(cropsId, SecurityConstants.INNER);
        return integerR.getData();

    }

    @Override
    public List<TraceTask> queryTaskList() {
        return traceTaskMapper.queryTaskList();
    }

    @Override
    public int productOutFactory(String cropsId) {
        R<Integer> integerR = remoteFarmerService.productOutFactory(cropsId, SecurityConstants.INNER);
        return integerR.getData();
    }



}
